<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>ELement对象</title>
	</head>
	<body>
		<a>点我试一试</a>
		<input type="button" id="btn_set" value="设置属性" />
		<input type="button" id="btn_rem" value="删除属性" />
		<script>
			//获取id
			var btn_set = document.getElementById("btn_set");
			btn_set.onclick = function(){
				//获取元素标签
				var element_a = document.getElementsByTagName("a")[0];
				
				element_a.setAttribute("href","https://www.baidu.com");
			}
			
			//获取id
			var btn_rem = document.getElementById("btn_rem");
			btn_rem.onclick = function(){
				//获取元素标签
				var element_a = document.getElementsByTagName("a")[0];
				
				element_a.removeAttribute("href");
			}
			
		</script>
	</body>
</html>
